import java.util.*;

public class Demo1 {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        list.
        PriorityQueue<Integer> queue = new PriorityQueue<>();
        queue.offer(10);
        queue.offer(2);
        queue.poll();
        System.out.println(queue.peek());
    }
}
class Solution {
    public int[] avoidFlood(int[] rains) {
        int n = rains.length;
        int[] ans = new int[n];
        Arrays.fill(ans, 1);
        TreeSet<Integer> st = new TreeSet<Integer>();
        Map<Integer,Integer> map = new HashMap<>();//哪天没下雨
        for(int i=0; i<n; i++){
            if(rains[i] == 0){
                st.add(i);
            }else{
                ans[i] = -1;//啥事干不了
                if(map.containsKey(rains[i])){
                    Integer it = st.ceiling(map.get(rains[i]));
                    if(it == null){
                        return new int[0];
                    }
                    ans[it]=rains[i];
                    st.remove(it);
                }
                map.put(rains[i],i);
            }
        }
        return ans;
    }
}
